﻿using System;
using GameLogic.Controls;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;

namespace GameLogic.Pages
{
    public partial class GamePage : PhoneApplicationPage
    {
        private bool _gameFinished;

        public GamePage()
        {
            InitializeComponent();

            this.Loaded += (s, e) =>
                {
                    _game = GameContainer.GameControlStatic as IGameFeatures;
                    _game.LivesChanged += (s1, e1) =>
                        {
                          
                        };
                    _game.ScoresChanged += (s1, e1) =>
                        {
                            
                        };
                    _game.GameOver += (s1, e1) =>
                        {
                            _gameFinished = true;
                        };

                    _gameFinished = false;
                    _game.Start();

                    NavigationService.Navigating += (s1, e1) =>
                        {
                            //if (MessageBox.Show(
                            //    "Game is running, do you want to quit?",
                            //    "Navigating away?",
                            //    MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
                            //{
                            //    e1.Cancel = true;
                            //}
                        };
                };
        }

        IGameFeatures _game;

        private void _pauseButton_Click(object sender, EventArgs e)
        {
            GameContainer.Game.Pause();
        }

        private void _playButton_Click(object sender, EventArgs e)
        {
            GameContainer.Game.Start();
        }

        private void _cancelButton_Click(object sender, EventArgs e)
        {
            GameContainer.Game.Stop();
        }

    }
}
